package com.missilike.core.result;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper = true)
@Data
public class PageListResult<T> extends CommonResult {


    /**
     * 是否有下一页
     */
    private boolean hasNextPage;

    /**
     * 页码
     */
    private long pageNum;

    /**
     * 每页大小
     */
    private long pageSize;

    /**
     * 总记录数
     */
    private long total;

    /**
     * 总页数
     */
    private long pages;

    /**
     * 当前页记录数
     */
    private int size;

    @SuppressWarnings(value = "unchecked")
    public PageListResult(Page<T> page) {
        super();
        this.setData(page.getRecords());
        this.hasNextPage = page.hasNext();
        this.pageNum = page.getCurrent();
        this.pageSize = page.getSize();
        this.total = page.getTotal();
        this.pages = page.getPages();
        this.size = page.getRecords().size();
    }


}
